#include <iostream>
#include "stack.h"
#include "status.h"
using namespace std;

bool match(Stack<char> & stack);

int main()
{
	//Stack<int> stack;
	//for (int i = 0; i < 5; i++)
	//{
	//	stack.Push(i + 1);
	//}

	//stack.StackTraverse();

	//cout << "***************" << endl << endl;

	//int i;
	//stack.Pop(i);

	//stack.StackTraverse();
	//cout << "长度为：" << stack.StackLength() << endl;
	//cout << "崩出来的是：" << i << endl;

	//cout << "******************" << endl << endl;

	//stack.ClearStack();
	//for (int i = 10; i > 0; i--)
	//	stack.Push(i);

	//stack.StackTraverse

	Stack<char> stack;
	if (match(stack))
		cout << "match" << endl;
	else
		cout << "not match" << endl;

	system("pause");
}

bool match(Stack<char> & stack)
{
	stack.ClearStack();
	char ch;
	cin.get(ch);
	while (ch != '\n')
	{
		char ch_tmp;
		switch (ch)
		{
		case '(':
		case '[':
		case '{':
			stack.Push(ch);
			break;
		case ')':
			if (stack.Pop(ch_tmp) == ERROR || ch_tmp != '(')
				return false;
			break;
		case ']':
			if (stack.Pop(ch_tmp) == ERROR || ch_tmp != '[')
				return false;
			break;
		case '}':
			if (stack.Pop(ch_tmp) == ERROR || ch_tmp != '{')
				return false;
			break;
		default:
			break;
		}
		cin.get(ch);
	}

	if (stack.StackEmpty())
		return true;

	return false;
}